program makemulti;
Var
   o,i,j	      : integer;
   t		      : array[1..10000,1..5] of integer;
   ba		      : array[1..2,1..5] of integer;
   tnodes,omult,multi : integer;
begin
   readln(multi);
   for i:=1 to 2 do begin
      for o:=1 to 5 do read(ba[i,o]); readln;
   end;
   readln(tnodes,omult);
   for i:=1 to tnodes do begin
      for o:=1 to 5 do read(t[i,o]); readln;
   end;
   {export}
   for i:=1 to 2 do begin
      for o:=1 to 5 do write(ba[i,o]:1,' '); writeln;
   end;
   writeln(tnodes*multi:1,' ',omult*multi:1,' # created by makemulti');
   for i:=1 to multi do begin
      for j:=1 to tnodes do begin
	 for o:=1 to 5 do write(t[j,o]:1,' '); writeln;
      end;
   end;
end.